/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.test;

import com.comac.ins.isfd.domain.*;
import com.comac.ins.isfd.service.IIsfdMeshOP2CompareService;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;


@SpringBootTest
public class IsfdMeshOP2CompareServiceImplTest {

    @Autowired
    private IIsfdMeshOP2CompareService compareService;

    @BeforeAll
    static void setup() {
        System.out.println("初始化测试环境...");
    }

    @Test
    @Order(1)
    public void testCompareOP2() {

        String taskIdStr = "67ee38d0445e661dc1b0b781";
        IsfdMeshOp2CompareTask task = new IsfdMeshOp2CompareTask();

        // Step1
        IsfdMeshOp2CompareObject baseObj = new IsfdMeshOp2CompareObject();
        baseObj.setUploadId("04162025");
        baseObj.setBaseRound(1);
        baseObj.setModelNumber("C919");
        baseObj.setBatchNumber("克卜勒-R2");
        baseObj.setSectionNumbers("S11");
        baseObj.setRoundNumber("测试轮次1");

        IsfdMeshOp2CompareObject compareObj1 = new IsfdMeshOp2CompareObject();
        compareObj1.setUploadId("67ee38d0445e661dc1b0b781");
        compareObj1.setBaseRound(2);
        compareObj1.setModelNumber("C929");
        compareObj1.setBatchNumber("克卜勒-R2");
        compareObj1.setSectionNumbers("S11");
        compareObj1.setRoundNumber("测试轮次2");

        task.setStepOne(new ArrayList<>(Arrays.asList(baseObj, compareObj1)));

        // Step2
        IsfdMeshOp2CompareItemRef compareItem1 = new IsfdMeshOp2CompareItemRef();
        compareItem1.setMatchKey("force.cbar_force.axial");
        compareItem1.setItemName("机身顶部长桁轴力");
        IsfdMeshOp2CompareItemRef compareItem2 = new IsfdMeshOp2CompareItemRef();
        compareItem2.setMatchKey("force.cquad4_force.mx");
        compareItem2.setItemName("机身环向蒙皮剪力x");
        IsfdMeshOp2CompareItemRef compareItem3 = new IsfdMeshOp2CompareItemRef();
        compareItem3.setMatchKey("force.cquad4_force.my");
        compareItem3.setItemName("机身环向蒙皮剪力y");
        IsfdMeshOp2CompareItemRef compareItem4 = new IsfdMeshOp2CompareItemRef();
        compareItem4.setMatchKey("force.ctria3_force.bmxy");
        compareItem4.setItemName("翼盒前梁单元剪力");
        task.setStepTwo(new ArrayList<>(Arrays.asList(compareItem1, compareItem2, compareItem3, compareItem4)));

        // Step3
        IsfdMeshOp2UnitNodeList unitNodeList = new IsfdMeshOp2UnitNodeList();
        unitNodeList.setTemplateUploadUrl("C:\\Users\\lijpt\\OneDrive\\Documents\\COMAC\\ISFD\\结果库\\测试用-节点清单.xlsx");
        task.setStepThree(unitNodeList);

        // 基本信息
        task.set_id(taskIdStr);
        task.setSectionNumbers(Collections.singletonList("S11"));
        task.setTaskName("测试对比任务");

        compareService.saveCompareResult(task, taskIdStr);

        return;
    }

    @Test
    @Order(2)
    public void testGetCompareResult() {

        String taskIdStr = "67ee38d0445e661dc1b0b781";

        // 获取结果
        IsfdMeshOp2CompareResult compareResult = compareService.getCompareReport(taskIdStr);

        return;
    }


    @AfterAll
    static void cleanup() {
        System.out.println("清理测试环境...");
    }
}
